package com.chapter12.self_define_exception;

import org.w3c.dom.ls.LSOutput;

public class Test extends RuntimeException{
    public static void main(String[] args) {
        P p = new P();
        p.f1(new Person("Tom",1));
    }

    public static void main() {
        System.out.println("重写后的异常");
    }
}


class P {

    public void f1(Person p1){
        if(p1.getAge() >= 18 && p1.getAge() <= 120){

        } else {
            Test.main();
        }
    }

}

class Person {
    private String name;
    private int age;
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}













